package com.um.jdy.platform.market.controller;

import com.um.jdy.common.market.entity.dto.ActivityDTO;
import com.um.jdy.common.market.entity.po.Activity;
import com.um.jdy.common.market.entity.vo.ActivityVO;
import com.um.jdy.common.market.service.ActivityService;
import com.um.jdy.platform.market.entity.dto.ActivityPageDTO;
import com.um.jdy.platform.market.entity.dto.SaveGroupDTO;
import com.um.jdy.platform.market.entity.dto.SaveSeckillDTO;
import com.um.jdy.platform.market.entity.vo.ActivityGoodsResultVO;
import com.um.jdy.platform.market.entity.vo.GroupResultVO;
import com.um.jdy.platform.market.entity.vo.SeckillResultVO;
import com.um.jdy.platform.market.entity.vo.SeckillTimesGoodsVO;
import com.um.jdy.platform.market.manager.ActivityManager;
import com.um.springboot.starter.annotation.ApiPermission;
import com.um.springboot.starter.annotation.TokenRequired;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.controller.BasePlusController;
import com.um.springboot.starter.orm.entity.Response;
import com.um.springboot.starter.orm.params.ListDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 控制器：平台活动表
 */
@RestController
@RequestMapping("/api/v1/market/activity")
@Api(tags = "ChargeActivityController", description = "平台活动表")
@ApiPermission("activity")
@TokenRequired
public class ActivityController extends BasePlusController<ActivityManager, ActivityService, Activity, ActivityDTO, ActivityVO, ActivityPageDTO, ListDTO> {

    @ApiPermission("page")
    @ApiOperation("分页查询活动")
    @PostMapping("get_activity_page")
    public Response<Page<ActivityVO>> getActivityPage(@RequestBody ActivityPageDTO pageDTO) {
        return Response.success(manager.getActivityPage(pageDTO));
    }

    @ApiPermission("get_seckill")
    @ApiOperation("秒杀详情")
    @PostMapping("get_activity_seckill_goods")
    public Response<SeckillResultVO> getActivitySeckillGoods(@RequestBody ActivityDTO activityDTO) {
        return Response.success(manager.getActivitySeckillGoods(activityDTO));
    }

    @ApiPermission("save_seckill")
    @ApiOperation("保存秒杀活动")
    @PostMapping("save_seckill")
    public Response saveSeckill(@RequestBody SaveSeckillDTO seckillDTO) {
        boolean result = manager.saveSeckill(seckillDTO);
        return result ? Response.success() : Response.failed();
    }

    @ApiPermission("save_group")
    @ApiOperation("保存拼团活动")
    @PostMapping("save_group")
    public Response saveGroup(@RequestBody SaveGroupDTO saveGroupDTO) {
        boolean result = manager.saveGroup(saveGroupDTO);
        return result ? Response.success() : Response.failed();
    }

    @ApiPermission("get_group")
    @ApiOperation("拼团详情")
    @PostMapping("get_activity_goods")
    public Response<GroupResultVO> getActivityGoods(@RequestBody ActivityDTO activityDTO) {
        return Response.success(manager.getActivityGoods(activityDTO));
    }

}
